The difference between delete and delete [] in C++

Posted by Ilya Melamed on Stack Overflow See other posts from Stack Overflow or by Ilya Melamed
Published on 2011-01-12T15:50:14Z Indexed on 2011/01/12 15:53 UTC
Read the original article Hit count: 122

Filed under:
|

I've written a class that contains two pointers, one is char* color_ and one in vertexesset* vertex_ where vertexesset is a class I created. In the destractor I've written at start

delete [] color_;
delete [] vertex_;

When It came to the destructor it gave me a segmentation fault.

Then I changed the destructor to:

delete [] color_;
delete vertex_;

And now it works fine. What is the difference between the two?

© Stack Overflow or respective owner

Related posts about c++

Related posts about memory-allocation